/**
 * Created by pzs on 20171031  复核日志js数据处理页面.
 */

angular.module('backofficeApp.reexamineLogManager.controller', [])
    .controller('reexamineLogCtrl', ['$scope','$http','$routeParams','$location', function ($scope, $http,$routeParams,$location) {

        $scope.currentPage = 1;
        $scope.pageSize = 15;

        //分页
        $scope.pagination = new pagination({currentPage:$scope.currentPage,pageSize: $scope.pageSize,
            url:'http://' + backOfficeHost + '/rest/v1.0/commission/reexamineLog/search/:page/:size',
            ajax: $http,
            success:function(data){
                if(data && data.data) {
                    $scope.mtOrderList = data.data.list;
                    $scope.pageNumber = data.data.totalPage;
                    $scope.count = data.data.count;
                    $scope.currentPage = $(".am-active").text();
                    $scope.pagination.totalPage = data.data.totalPage;
                }
                $scope.pagination.pageHeader($scope.pageNumber);
                $('#count').text("共"+$scope.pageNumber+"页 有"+$scope.count+"数据");
            },
            error: function(err){
                //$scope.communityList = null;
            },
            params: {}
        });

        //搜索
        $scope.search = function (current) {

            if (current) {
                $scope.currentPage = $scope.pagination.currentPage;
            }else {
                $scope.pagination.currentPage = 1;
                $scope.currentPage = 1;
            }

            var startDateSelect = $("#startDateSelect").val();
            if(startDateSelect == '') {
                alert('开始日期不能为空！');
                return;
            }
            var endDateSelect = $("#endDateSelect").val();
            if(endDateSelect == '') {
                alert('结束日期不能为空！');
                return;
            }
            if(startDateSelect > endDateSelect) {
                alert('开始日期不能大于结束日期！');
                return;
            }

            var opt = {
                startdate:startDateSelect,
                enddate:endDateSelect,
                errorStatus:$scope.errorStatus
            };
            //if ($scope.status) opt.status = $scope.status;
            $http.post('http://' + backOfficeHost + '/rest/v1.0/commission/reexamineLog/search/' + $scope.currentPage  + '/' + $scope.pageSize, opt, {
                headers: {'Content-Type': 'application/json;charset=utf-8'}
            }).success(function (data) {
                $scope.mtOrderList = data.data.list;
                $scope.pageNumber = data.data.totalPage;
                $scope.count = data.data.count;
                $scope.currentPage = $(".am-active").text();
                $scope.pagination.totalPage = data.data.totalPage;
                $scope.pagination.pageHeader($scope.pageNumber);
                <!--  宝宝树66小区三次改造    mod   guo.xiaomin  20171017  start   -->
                // 追加,解决分页搜索问题
                $scope.pagination.searchParams = opt;
                <!--  宝宝树66小区三次改造    mod   guo.xiaomin  20171017  end   -->
                $('#loading').modal("close");
            }).error(function (err) {
                $('#loading').modal("close");
                alert(err);
            });
        }

    }])